{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "`langchain-core>=0.2.16.`\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "d21d80bff8966e0a"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "from langchain_core.runnables import RunnableConfig\n",
    "from langchain_core.tools import tool\n",
    "\n",
    "\n",
    "@tool\n",
    "async def reverse_tool(text: str, special_config_param: RunnableConfig) -> str:\n",
    "    \"\"\"A test tool that combines input text with a configurable parameter.\"\"\"\n",
    "    return (text + special_config_param[\"configurable\"][\"additional_field\"])[::-1]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-31T05:04:37.352058Z",
     "start_time": "2024-10-31T05:04:36.104483Z"
    }
   },
   "id": "32131b7330bf3cd5",
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "'321cba'"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "await reverse_tool.ainvoke(\n",
    "    {\"text\": \"abc\"}, config={\"configurable\": {\"additional_field\": \"123\"}}\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-31T05:04:50.301998Z",
     "start_time": "2024-10-31T05:04:50.280851Z"
    }
   },
   "id": "1601b8792442343d",
   "execution_count": 2
  },
  {
   "cell_type": "markdown",
   "source": [
    "你现在已经学会了如何在工具中配置和流式传输事件。接下来，查看以下指南以了解更多关于使用工具的信息：\n",
    "- [如何从工具中流式传输事件](https://python.langchain.com/docs/how_to/tool_stream_events/)\n",
    "- [如何将工具输出传递给聊天模型](https://python.langchain.com/docs/how_to/tool_results_pass_to_model/)\n",
    "\n",
    "你也可以查看一些更具体的工具调用使用：\n",
    "- 构建[使用工具的链和代理](https://python.langchain.com/docs/how_to/#tools)\n",
    "- 从模型中获取[结构化](https://python.langchain.com/docs/how_to/structured_output/)输出\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "927cfd5a3653144"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "a2b86834ab89766f"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
